<%@page import="cn.jhc.dao.MsgDao"%>
<%@page import="cn.jhc.dao.ConnectionFactory"%>
<%@page import="cn.jhc.bean.MsgBean"%>
<%@page import="java.util.ArrayList"%>
<%@page import="cn.jhc.bean.UserBean"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="./css/taolunqu.css"></link>
<title>留言板</title>
</head>
<body>
	<%
		int CurrentPage = 1;
		int intPageCount;
		if (request.getParameter("page") != null)
			CurrentPage = Integer.parseInt(request.getParameter("page"));
		if (CurrentPage < 1)
			CurrentPage = 1;
	%>

	<div id="wrapper">
		<jsp:include page="./header.jsp"></jsp:include>
		<%
			ArrayList<MsgBean> m = new ArrayList<MsgBean>();
			MsgDao dao = new MsgDao();
			dao.setCon(ConnectionFactory.getConnection());
			m = dao.getAllMessages(CurrentPage);
			request.setAttribute("title", m);
		%>
		<%
			MsgDao dao2 = new MsgDao();
			dao2.setCon(ConnectionFactory.getConnection());
			intPageCount = dao2.getCount();
			if (CurrentPage > intPageCount)
				CurrentPage = intPageCount;
		%>
		<div id="topall">
			<div id="toptitle">主题</div>
			<div id=toptime>时间</div>
			<div id=topname>作者</div>
		</div>
		<c:forEach var="ti" items="${requestScope.title}">
			<div id="order">
				<div id="newtitle">
					<a href="showonemsg.do?id=${ti.id}">${ti.title}</a>
				</div>
				<div id="time">
					<a>${ti.date}</a>
				</div>
				<div id="displayname">
					<a>${ti.displayname}</a>
				</div>
			</div>
		</c:forEach>
		<div id="button">
			<form method="post" action="./msg.jsp">
				<input type="hidden" name="getb" value="/msg.jsp"> <input
					type="submit" value="开启一个新话题"></input>
			</form>
		</div>
		<div align="right">
			<a>第<%=CurrentPage%>页 共<%=intPageCount%>页
			</a> <a href="taolunqu.jsp?page=<%=1%>">首页</a>
			<%
				if (CurrentPage > 1) {
			%>
			<a href="taolunqu.jsp?page=<%=CurrentPage - 1%>">上一页</a>
			<%
				} else {
			%>
			上一页
			<%
				}
			%>
			<%
				if (CurrentPage >= intPageCount) {
			%>
			下一页
			<%
				} else {
			%>
			<a href="taolunqu.jsp?page=<%=CurrentPage + 1%>">下一页</a>
			<%
				}
			%>
			<a href="taolunqu.jsp?page=<%=intPageCount%>">末页</a>
		</div>
	</div>
</body>
</html>




